package com.maycurobj;

import com.alibaba.fastjson.JSONObject;
import com.maycur.developer.sdk.maycur.ultimate.openapi.request.PostEmployeeBatchRequest;
import com.maycurobj.pojo.EhrEmployeeInfo;
import com.maycurobj.service.impl.EhrService;
import com.maycurobj.service.impl.MaycurService;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * ehr 与 maycur同步的
 * 测试类
 * 同时可以用于临时同步或更新上级
 */
@SpringBootTest
class MaycurobjApplicationTestForEHR {
//
    @Autowired
    private EhrService ehrService;

    @Autowired
    private MaycurService maycurService;


    @Test
    void contextLoads() {
    }

    /**
     * 可以用于更新上级用户用
     */
    @Test
    public void handlerEhrToMaycurUserParent() {
        //获取ehr userinfo
        Map<String, Object> ehrmap = ehrService.getEHRUserInfo();
        //整理ehr组织结构人员明细
        List<EhrEmployeeInfo> ehrList=(List<EhrEmployeeInfo>)ehrmap.get("ehrObject");
        System.out.println("打印下ehr的记录----->>>>" + JSONObject.toJSONString(ehrList));
        maycurService.employEhrToMayCur(ehrList);
    }



    @Test
    public void setMaycurEmployeeInfo(){
        List<PostEmployeeBatchRequest.User> reqUserList = new ArrayList<>();
        PostEmployeeBatchRequest.User user = new PostEmployeeBatchRequest.User();
        List<PostEmployeeBatchRequest.RTRoute> rtRoutes = new ArrayList<>();
        PostEmployeeBatchRequest.RTRoute rtRoute = new PostEmployeeBatchRequest.RTRoute();
        user.setEmployeeId("ZJBS000236");
        user.setEmployeeName("王洋生");
        user.setPhoneNo("17357156365");
        rtRoute.setBusinessCode("DI48655993963289739");
        rtRoute.setSupervisorEmployeeId("ZJBS000008");
        rtRoute.setDefaultDepartment(true);
        rtRoutes.add(rtRoute);
        user.setDepartments(rtRoutes);
        reqUserList.add(user);
        try {
            maycurService.pushMaycurEmployeeFunction(reqUserList);
        }catch (Exception ex) {
            ex.printStackTrace();
        }

    }

    /**
     * 王丽丽(1102 mobile: 18698406267 ) 临床学术 DI14210530818396280  1015上级
     *       内蒙大区 DI14210564383315082  1015上级
     * 王洋生(73 mobile:17357156365 ZJBS000236) 助理总经理分管部门 DI22731948369647753  ZJBS000008 上级
     *       华北省区 DI48655993963289739  ZJBS000008 上级
     *
     */

}
